package com.frost.demo.ioc.controller;

import com.frost.demo.ioc.model.Dbtypes;
import com.frost.demo.ioc.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/yml")
@RestController
public class YmlController {

    @Value("${frost.value1}")
    private String value1;

    @Value("${frost.value2}")
    private String value2;

    @RequestMapping("/readValue")
    public String readValue() {
        return "从Yml读取配置文件, value1: " + value1 + ", value2: " + value2;
    }

    @Autowired
    private Student student;

    @RequestMapping("/readStu")
    public String readStu() {
        return student.toString();
    }

    @Autowired
    private Dbtypes dbtypes;

    @RequestMapping("/types")
    public String readTypes() {
        return dbtypes.toString();
    }


    @Value("${string.str1}")
    private String str1;
    @Value("${string.str2}")
    private String str2;
    @Value("${string.str3}")
    private String str3;

    @RequestMapping("readStr")
    public void readStr() {
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);
    }
}
